﻿using System;
using System.Data;
using System.Data.SqlServerCe;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    class SelectBuyPointDialogPresenter
    {
        private SelectBuyPointDialogModel _model;
        private ISelectBuyPointDialogView _view;

        public SelectBuyPointDialogPresenter(ISelectBuyPointDialogView view)
        {
            _model = new SelectBuyPointDialogModel();
            _view = view;
            _view.SetBuyerList(_model.GetBuyer(), "[nameClient]");
            _view.SelectedBuyer += SelectedFilter;
            _view.SelectedBuyPoint += SelectedBuyPoint;
        }

        public void SelectedFilter (object sender, EventArgs e)
        {
            //SqlCeDataReader dr = ((SqlCeDataReader) _view.GetBuyerFilterValue);
            //dr.Read();
            //int idBuyer = dr.GetInt32(0);
             
            //_view.SetBuyPointsList(_model.GetBuyPoint(idBuyer),"NameBuyPoint");
        }

        public void SelectedBuyPoint (object sender, EventArgs e)
        {
            _view.AdressBuyPoint = (string)((SqlCeDataReader) _view.GetBuyerFilterValue)["Adress"];
        }
    }
}
